#include "WatchDog.h"
#include "Globle.h"
#include "MyVersion.h"


#ifdef __PEER__
	#define WATCHDOG 0
#else
	#define WATCHDOG 0
#endif

#ifdef  __cplusplus
extern "C" {
#endif
	
extern unsigned long DogCheck(void);
extern unsigned long ReadDog(void);
extern unsigned long DogConvert(void);
extern unsigned long WriteDog(void);
extern unsigned long GetCurrentNo(void);
extern unsigned long SetDogCascade(void);
extern unsigned long SetPassword(void);
	
short int DogBytes,DogAddr;
unsigned long DogPassword;
unsigned long NewPassword;
unsigned long DogResult;
unsigned char DogCascade;
void * DogData;

Bool WD_Initialize()
{
	DogCascade=0;
	DogPassword=0;
	return TRUE;
}

Bool WD_IsValid()
{
#if WATCHDOG > 0
	return DogCheck() == 0;
#else
	return TRUE;
#endif
}

Bool WD_SaveServiceConfig()
{
#if WATCHDOG > 0
	UInt32 config = GetServiceConfig();
	DogData = &config;
	DogAddr = 0;
	DogBytes = 4;
	return WriteDog() == 0;
#else
	return TRUE;
#endif
}

Bool WD_LoadServiceConfig()
{
#if WATCHDOG > 0
	UInt32 config = 0;
	DogData = &config;
	DogAddr = 0;
	DogBytes = 4;
	if( ReadDog() == 0 )
	{
		SetServiceConfig( config );
		return TRUE;
	}
	else
		return FALSE;
#else
	return TRUE;
#endif
}

#ifdef  __cplusplus
}
#endif

